# Maintainer: The MyPaint Team <mypaintopensource@gmail.com>

_realname=libmypaint
_realver=1.5.1
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
conflicts=("${MINGW_PACKAGE_PREFIX}-mypaint<1.3.0alpha")
pkgver=${_realver/-/}
pkgrel=2
pkgdesc="Brush engine used by MyPaint (mingw-w64)"
arch=('any')
url="http://mypaint.org"
license=("ISC")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-glib2"
             "git")
# autotools are required because several Makefile.am are modified
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-json-c")
options=('strip' '!debug')
source=("https://github.com/mypaint/${_realname}/releases/download/v${_realver}/${_realname}-${_realver}.tar.xz")
sha256sums=('aef8150a0c84ce2ff6fb24de8d5ffc564845d006f8bad7ed84ee32ed1dd90c2b')

prepare() {
  cd ${_realname}-${_realver}
  autoreconf -fiv
}

build() {
  #export GI_SCANNER_DEBUG="save-temps"
  cd "${srcdir}"
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  cp -rf ${_realname}-${_realver} build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}
  #mkdir -p build-${MINGW_CHOST}
  #cd build-${MINGW_CHOST}


  PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/share/pkgconfig" \
  ./configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --enable-shared \
    --enable-static

  make
}

package() {
  cd "${srcdir}"/build-${MINGW_CHOST}
  make -j1 DESTDIR="${pkgdir}" install
  install -Dm644 ${srcdir}/${_realname}-${_realver}/COPYING "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
